<template>
  <!-- 登录页面静态搭建 -->
  <div class="login_container">
    <el-row>
      <el-col :span="12" :xs="0"></el-col>
      <el-col :span="12" :xs="24">
        <el-form class="login_form">
          <h1>Hello</h1>
          <h2>欢迎来到硅谷甄选</h2>
          <el-form-item>
            <el-input
              :prefix-icon="User"
              v-model="loginForm.username"
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-input
              type="password"
              :prefix-icon="Lock"
              v-model="loginForm.password"
              show-password
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button class="loginButton" type="primary" @click="login">
              登录
            </el-button>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
  </div>
</template>

<script setup lang="ts">
import { User, Lock } from '@element-plus/icons-vue'
import { reactive } from 'vue'
//引入用户登录的小仓库
import useUserStore from '@/store/modules/user'
let useStore = useUserStore()
//收集账号和密码的信息
let loginForm = reactive({ username: '', password: '' })
//登录按钮回调
const login = () => {
  //点击登录按钮以后干什么?
  //通知仓库发登录请求
  //请求成功后->首页展示数据的地方
  //请求失败->弹出登录失败信息

  // console.log("登录信息",loginForm)
  useStore.userLogin(loginForm)
}
</script>

<style lang="scss" scoped>
.login_container {
  width: 100%;
  height: 100vh;
  background: url('@/assets/images/background.jpg') no-repeat;
  background-size: cover;
  .login_form {
    position: absolute;
    width: 40%;
    top: 30vh;
    padding: 40px;
    background: url('@/assets/images/login_form.png') no-repeat;
    background-size: cover;
    h1 {
      font-size: 40px;
      color: white;
    }
    h2 {
      margin: 20px 0 20px 0;
      font-size: 20px;
      color: white;
    }
    .loginButton {
      width: 100%;
    }
  }
}
</style>
